import { ethers } from 'ethers'
import {
  getProvider,
  getProviderFromAction,
  getJsonRpcProvider,
} from './provider'

const getSigner = () => {
  return getProvider().getSigner(0)
}

const getTestSigner = (action) => {
  let provider = getProviderFromAction(action)
  let privateKey = action.web3.eth.accounts.wallet[0]
  return new ethers.Wallet(privateKey, provider)
}

const getWalletFromPrivateKey = (privateKey) => {
  let provider = getJsonRpcProvider()
  return new ethers.Wallet(privateKey, provider)
}

export { getSigner, getTestSigner, getWalletFromPrivateKey }
